function wrapFun(pre, wrapper) {
  return function () {
    try {
      wrapper && wrapper.apply(this, arguments)
    } finally{
      pre && pre.apply(this, arguments)
    }
  }
}

// https://regexr.com/4je5c
module.exports = function () {
  let ret = {
    initStaticRef(onLoad, refs, opt) {
      return wrapFun(onLoad, function () {
        this.$staticRefs = {}
        refs.forEach(v => {
          let k = v.trim().replace(/^(ref-)/, '')
          this.$staticRefs[k] = this.selectComponent('#' + v)
        })
        // console.log('this', opt, refs)
      })
    }
  }
  return ret
}
